<template>
  <el-tabs type="border-card">
    <el-tab-pane label="我要成为商户">
      <el-form :inline="true" class="demo-form-inline">
        <Addr ref="Addr"></Addr>
        <br>
        <el-form-item>
          <el-button type="primary" @click="submitForm">提交申请</el-button>
        </el-form-item>
      </el-form>
    </el-tab-pane>
  </el-tabs>
</template>

<script>
    import Addr from "../Addr";
    export default {
        name: "apply_for_commercial",
        data(){
          return{
            addForm: {
            }
          }
        },
        methods:{
          submitForm() {
            //进行提交，获取子数据
            //数据组装
            //获取选择的自提地址对象
            this.addForm["deliveryAddressPick"]=this.$refs["Addr"].delivery_address;
            console.log(this.$refs["Addr"].delivery_address);
            console.log(this.addForm);
            //调用异步，申请成为商户
            this.$axios.put("apply_for_commercial.action",this.addForm)
              .then(res=>{
                if(res.data.x){
                  this.$message.success(res.data.msg);
                  //重定向路由
                  this.$router.push("/");
                }else {
                  this.$message.error(res.data.msg);
                }
              })
              .catch(err=>{
                this.$message.warning(err);
                alert(err);
              })
          },
        },
        components:{
          Addr
        }
    }
</script>

<style scoped>

</style>
